package com.sdu.cloudservice.action;

import com.sdu.cloudservice.service.InstanceService;
import com.sdu.cloudservice.token.UserToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by lenovo on 2019/6/25.
 * @author
 * ZMX
 */
@Controller
@CrossOrigin
@RequestMapping("/instance")
public class InstanceAction {
    @Autowired
    private InstanceService instanceService;

    @RequestMapping(value = "/getConfigInfo",method = RequestMethod.GET)
    @ResponseBody
    @UserToken
    public String getConfigInfoAction(){
            return instanceService.getConfigInfo().toString();
    }

    @RequestMapping(value = "/getRegions",method = RequestMethod.GET)
    @ResponseBody
    @UserToken
    public String getRegionsAction(){
        return instanceService.getRegions().toString();
    }

    @RequestMapping(value = "/getZoneByRegionId",method = RequestMethod.GET)
    @ResponseBody
    @UserToken
    public String getZoneByRegionId(String regionId){
        return instanceService.getZoneByRegionId(regionId).toString();
    }

    @RequestMapping(value = "/getInstanceByZoneId",method = RequestMethod.GET)
    @ResponseBody
    @UserToken
    public String getInstanceByZoneId(String zoneId){
        return instanceService.getInstanceByZoneId(zoneId).toString();
    }
}
